Feature: 动态
  作为一个律团律师用户
  我可以通过动态和其他律师进行交互


# 不成功

Scenario: 只有律师用户才可以创建动态，不是的话则报401错误
Given a normal user "1" exists with:
    | username    | password   |
    | 13702321155 | 123456   |
    And http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13702325511 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/create" with:
        | content    | imageIds  |
        | 12123 |       |
    Then the response status code should be 401
    And the response is in "json" format

Scenario: 创建动态的时候，内容不能为空，不是的话则报400错误
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/create" with:
        | content    | imageIds   |
        |                  |            |
    Then the response status code should be 400
    And the response is in "json" format
    And I got error message "请填写内容" for field "content"

Scenario: 创建动态的时候，内容要在0到140个字符之间，不是的话则报400错误
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/create" with:
        | content    | imageIds   |
        |   dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd               |            |
    Then the response status code should be 400
    And the response is in "json" format
    And I got error message "内容长度在0到140之间" for field "content"

Scenario: 创建动态的时候，如果上传超过9张图片，则报400错误(POST _/microblog/uploadImage/{field?})（有问题）
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/uploadImage" with:
    | imageIds    | 
    | ["1","2","3","4","5","6","7","8","9","10"] | 
    Then the response status code should be 400
    And the response is in "json" format

Scenario: 如果访问一个不存在的动态的详情，则会报404错误
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And print last response
    And http "authorization" header exists
    And I am on "/microblog/12333/view"
    Then the response status code should be 404
    And the response is in "json" format
    And I see error message "该动态不存在" for field "error_messages"

Scenario: 只有动态创建者才可以删除动态，如果不是的话会报401错误(GET _/microblog/{post_id}/delete)
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I am on "/microblog/453/delete"
    Then the response status code should be 401
    And the response is in "json" format
    And I see error message "您没有权限删除该动态" for field "message"

Scenario: 如果删除一个不存在的动态，则会报404错误
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I am on "/microblog/123321/delete"
    Then the response status code should be 404
    And the response is in "json" format
    And I see error message "该动态不存在" for field "error_messages"

Scenario: 如果评论一个不存在的动态，则会报400错误(POST _/microblog/{post_id}/comment/create)
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13702325511 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/15212/comment/create" with:
        |  content          | post_id |
        | 13702325511 | 15212 |
    Then the response status code should be 400
    And the response is in "json" format
    And I got error message "您要评论的动态不存在" for field "post_id"

Scenario: 如果评论一个动态的时候提交的内容为空，则会报400错误
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/455/comment/create" with:
        |  content          |
        |                        |
    Then the response status code should be 400
    And the response is in "json" format
    And I got error message "请填写内容" for field "content"

Scenario: 如果评论一个动态的时候提交的内容不在0到140个字符之间，则会报400错误
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13702325511 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/453/comment/create" with:
        |  content          |
        |   dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd                     |
    Then the response status code should be 400
    And the response is in "json" format
    And I got error message "内容长度在0到140之间" for field "content"


# 成功

Scenario: 创建动态 /microblog/create
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/create" with:
        | content    | imageIds   |
        | 115511 |           |
   Then the response status code should be 201
    And the response is in "json" format
    And I see elements in the response:
    | id |

Scenario: 转发动态 /microblog/forward
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13702325511 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/forward" with:
        | content    |  parent_id   |
        | 135511 |  473   |
   Then print last response
   Then the response status code should be 201
    And the response is in "json" format
    And I see message "473" for field "id" 

Scenario: 动态详情 /microblog/{post_id}/view
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I am on "/microblog/474/view"
    Then the response status code should be 200
    And the response is in "json" format
    And I see message "474" for field "id" 
    
Scenario: 删除动态 /microblog/{post_id}/delete
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13702325511 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/474/delete" with:
    Then the response status code should be 200
    And the response is in "json" format
    And I see error message "删除成功" for field "data"

Scenario: 列举所有动态 /microblog/list/all
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I am on "/microblog/list/all"
    Then the response status code should be 200
    And the response is in "json" format

Scenario: 列举我的动态 /microblog/list/mine
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13902310360 | 123456   |
    And http "authorization" header exists
    And I am on "/microblog/list/mine"
    Then the response status code should be 200
    And the response is in "json" format
    And I get message "3" for field "creator_id" 

Scenario: 评论一个动态 /microblog/{post_id}/comment/create
Given http "accept" header is "application/json"
    And I make a "post" request to "login" with:
        | username    | password   |
        | 13702325511 | 123456   |
    And http "authorization" header exists
    And I make a "post" request to "microblog/454/comment/create" with:
        | content    | post_id |
        | 1377 | 474 |
    Then the response status code should be 201
    And the response is in "json" format
    And I see message "454" for field "post_id"
